home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / C⁄C++ / Marathon Map Viewer / @Source / marathonTypes.h < prev    next >
Text File  |  1995-06-05  |  15KB  |  476 lines

  1. /*-----------------------------------------------------------------
  2.     Marathon data structures.
  3.     
  4.     The Map file consists of:
  5.     
  6.     mapHeader        // only one header
  7.     
  8.     level data for level 1..n    // data for each level.
  9.     
  10.     levelInfo[n]    // trailer info. one level info for each level
  11.     
  12.     
  13.     The level data consists of different chunks.
  14.     Each chunk is defined below.  Chunks can be in any order.
  15.     Not all chunks are needed but some are.
  16. -----------------------------------------------------------------*/
  17. #pragma once
  18.  
  19. #define MAX_VERTICIES        1024
  20. #define MAX_LINES            1024
  21. #define MAX_SIDES            1024
  22. #define MAX_POLYS            256
  23. #define MAX_LITES            32
  24. #define MAX_OBJECTS            256
  25. #define MAXIMUM_OBJECT_TYPES 64
  26.  
  27. // this is what a map header looks like
  28. typedef struct {
  29.     short            type;            // 0
  30.     unsigned short    flags;            // 0
  31.     char            name[64];        // c string
  32.     long            unused;
  33.     long            mapSize;        // offset to trailer info
  34.     short            numLevels;        // number of levels in map
  35.     short            unused2[25];    // not exactly unused?????
  36.     } mapHeader;
  37.  
  38. // this is the level info, or trailer.  One for each level
  39. typedef struct {
  40.     long        offset;                // number of bytes from start of file
  41.     long        size;                // size of level in bytes
  42.     } levelInfo;
  43.  
  44. // no longer used as level name.  Now used as authors name.
  45. typedef char        levelName[64];
  46.  
  47. // a chunk header
  48. typedef struct {
  49.     long        chunkType;            // type of chunk OSType
  50.     long        nextChunk;            // offset from level start to next chunk.  0 if last.
  51.     long        size;                // size of chunk data
  52.     // chunk data is here
  53.     } chunkHeader;
  54.  
  55. // a point
  56. typedef struct {
  57.     short        x,y;                // a signed value
  58.     } PNTSdata;
  59.  
  60. // flags for the end points
  61. enum {        // vertex flags
  62.     vertex_solid =             0x0001,        // ????
  63.     vertex_multiHeights =     0x002        // adjacent polys have different heights
  64.     };
  65.  
  66. // end points.  Do not use.  Use points instead.
  67. typedef struct {
  68.     unsigned short     flags;                // vertex flags
  69.     short            highestFloor;        // highest adjacent floor height
  70.     short            lowestCeiling;        // lowest adjacent ceiling height
  71.     short            x, y;
  72.     short            transformedX, transformedY;    // ????
  73.     short            polyIndex;            // ????
  74.     } EPNTdata;
  75.  
  76. enum {        // lines flags
  77.     line_solid =             0x4000,        // shots/player can not pass through
  78.     line_transparent =         0x2000,        // can see through, ie window
  79.     line_landScaped =        0x1000,
  80.     line_elevated =            0x0800,
  81.     line_variableElevation =0x0400
  82.     };
  83.  
  84. // when going from point b->a is how left/right is determined.
  85. typedef struct {
  86.     short            pointA;            // line goes from point a to b
  87.     short            pointB;
  88.     unsigned short     flags;            // line flags
  89.     short            length;            // length of line.  MUST be calced
  90.     short            highestFloor;    // highest adjacent floor height
  91.     short            lowestCeiling;    // lowest adjacent ceiling height
  92.     short            leftSide;        // the side on the left of the line (-1 for none)
  93.     short            rightSide;
  94.     short            leftPoly;        // the poly on the left of the line (-1 for none)
  95.     short            rightPoly;
  96.     short            unused[6];
  97.     } LINSdata;
  98.  
  99. enum {        // side flags
  100.     side_ControlPanelStatus = 0x0001,
  101.     side_ControlPanel =       0x0002,
  102.     side_RepairSwitch =       0x0004
  103. };
  104. enum {        // side types
  105.     side_Full,            // primary texture goes from ceiling to floor
  106.     side_High,            // primary texture goes from ceiling down
  107.     side_Low,            // primary texture goes from floor up
  108.     side_Composite,        // primary texture is from ceiling to floor, secondary texture is mapped on to it, ie control panel
  109.     side_Split            // primary from ceiling down, secondary from floor up
  110. };
  111. enum {        // control panel types
  112.     panel_Oxygen,
  113.     panel_Shield,
  114.     panel_DoubleShield,
  115.     panel_TripleShield,
  116.     panel_LightSwitch,        // permutaion = light index
  117.     panel_platformSwitch,    // permutation = platform index??
  118.     panel_PatternBuffer,
  119.     panel_Unused,
  120.     panel_CommTerminal,        // permutation = script index
  121.     panel_Switch,            // usually a repair switch
  122.     alienPanel_DoubleShield,
  123.     alienPanel_TripleShield,
  124.     alienPanel_platformSwitch,
  125.     alienPanel_PatternBuffer
  126. };
  127. enum {        // transfer modes for sides and polys
  128.    tNormal,            // normal texture mapping
  129.    tFadeToBlack,
  130.    tInvisible,
  131.    tSubInvisible,
  132.    tPulsate,         /* polygons only */
  133.    tWobble,         /* polygons only */
  134.    tFastWobble,     /* polygons only */
  135.    tStatic,
  136.    tSubStatic,
  137.    tLandscape,        // copy, no texture mapping, for views outside of window
  138.    tSmear,             /* flat shading of pixel at 0,0 */
  139.    tFadeOutStatic,
  140.    tPulsateStatic,
  141.    tFoldIn,            // appear
  142.    tFoldOut,        // disappear
  143.    tHorizSlide,
  144.    tFastHorizSlide,
  145.    tVertSlide,
  146.    tFastVertSlide,
  147.    tWander,
  148.    tFastWander
  149. };
  150.  
  151. // a texture.
  152. typedef struct {
  153.     short        xo, yo;            // offsets into texture
  154.     char        textureSet;        // texture set number
  155.     char        textureNum;        // texture number in set
  156.     } texture;
  157.  
  158. // prevents the side from being passable. (?overhead area rectangle?)
  159. // bungi says do not use
  160. typedef struct {
  161.     short        x1, y1;
  162.     short        x2, y2;
  163.     short        x3, y3;
  164.     short        x4, y4;
  165.     } exclusionZone;
  166.  
  167. // the sides data
  168. typedef struct {
  169.     short            type;
  170.     unsigned short    flags;
  171.     texture            primaryTexture;
  172.     texture            secondaryTexture;
  173.     texture            transparentTexture;
  174.     exclusionZone    theExclusionZone;            // do not use, set to -1
  175.     short            controlPanelType;
  176.     short            controlPanelPermutation;
  177.     short            primaryTransferMode;
  178.     short            secondaryTransferMode;
  179.     short            transparentTransferMode;
  180.     unsigned short    direction;                    // set to -1
  181.     short            lineIndex;                    // the line this side belongs to
  182.     short            unused[6];
  183.     } SIDSdata;
  184.  
  185. enum {        // poly flags
  186.     polygon_Detached =                  0x4000,
  187.     polygon_platformInitiallyOff =      0x2000,
  188.     polygon_platformInitiallyExtended = 0x1000
  189. };
  190. enum {        // poly types
  191.     polygon_Normal,
  192.     polygon_ItemImpassable,
  193.     polygon_MonsterImpassable,
  194.     polygon_MinorDamage,
  195.     polygon_MajorDamage,
  196.     polygon_platform,            // permutation = platform index
  197.     polygon_LightOnTrigger,        // permutation = light index
  198.     polygon_platformOnTrigger,    // permutation = polygon index
  199.     polygon_LightOffTrigger,    // permutation = light index
  200.     polygon_platformOffTrigger,    // permutation = polygon index
  201.     polygon_Teleporter,            // permutation = polygon index
  202.     polygon_Glue,                // monsters stay deactive
  203.     polygon_GlueTrigger,        // triggers all glue
  204.     polygon_Superglue,
  205.     polygon_MustExplore,        // must explore to end level
  206.     polygon_Exit                // if conditions met then teleport to next level
  207. };
  208.  
  209. // same as texture set but no offset
  210. typedef struct {
  211.    char         set;
  212.    char         frame;
  213.     } shapeDescriptor;
  214.  
  215. // the polygon
  216. typedef struct {
  217.     short            type;        // user editable
  218.     unsigned short    flags;        // user editable
  219.     short            permutation;    // user editable == platform number, light number
  220.     short            vertexCount;        // number of points in poly
  221.     short            vertexIndex[8];        // the point array index
  222.     short            lineIndex[8];        // the line from point -> point + 1
  223.     shapeDescriptor    floorTexture;        // user editable
  224.     shapeDescriptor    ceilingTexture;        // user editable
  225.     short            floorHeight;        // user editable
  226.     short            ceilingHeight;        // user editable
  227.     short            floorLightSource;    // user editable
  228.     short            ceilingLightSource;    // user editable
  229.     long            area;                // do we need to calc this????
  230.     short            firstObject;        // -1
  231.     short            firstExclusionZoneIndex;    // looks in the exclusion zone index array: -1
  232.     short            lineExclusionZoneCount;     // 0
  233.     short            pointExclusionZoneCount; // 0
  234.     short            floorTransferMode;        // user editable
  235.     short            ceilingTransferMode;    // user editable
  236.     short            adjacentPolys[8];        // the poly on the other side of this line
  237.     short            firstNeighborIndex;        // -1
  238.     short            neighborCount;            // 0
  239.     short            centerX;                
  240.     short            centerY;
  241.     short            sideIndex[8];            // the side on this line
  242.     short            unused[10];
  243.     } POLYdata;
  244.  
  245. enum {        // lite flags
  246.     light_Autotriggered = 0x4000
  247. };
  248. enum {        // lite types
  249.     light_Normal,
  250.     light_Rheostat,
  251.     light_Flourescent,
  252.     light_Strobe,
  253.     light_Flicker,
  254.     light_Pulsate,
  255.     light_Annoying,
  256.     light_EnergyEfficient
  257. };
  258. enum {        // lite modes
  259.     light_TurningOn,
  260.     light_On,
  261.     light_TurningOff,
  262.     light_Off,
  263.     light_Toggle
  264. };
  265. // the lighting data
  266. typedef struct {
  267.     unsigned short    flags;
  268.     short            type;
  269.     short            mode;
  270.     short            phase;
  271.     Fixed            minIntensity;
  272.     Fixed            maxIntensity;
  273.     short            period;
  274.     Fixed            intensity;
  275.     short            unused[5];
  276.     } LITEdata;
  277.  
  278. enum {        // object types
  279.     object_monster = 0,
  280.     object_scenery,
  281.     object_weapon,
  282.     object_player,
  283.     object_goal            // index = terminal data to display portions of map
  284.     };
  285. // the objects
  286. typedef struct {
  287.     short            type;            
  288.     short            index;            // depends on type, but from 0..n
  289.     short            facing;            // direction it is facing
  290.     short            polyIndex;        // what polygon this is in
  291.     short            x;                // its co-ords
  292.     short            y;
  293.     short            unused[2];
  294.     } OBJSdata;
  295.  
  296. enum {        // mission flags
  297.     mission_None =          0x0000,
  298.     mission_Extermination = 0x0001,
  299.     mission_Exploration =   0x0002,
  300.     mission_Retrieval =     0x0004,
  301.     mission_Repair =        0x0008,
  302.     mission_Rescue =        0x0010
  303. };
  304. enum {        // environment flags
  305.     environment_Normal =     0x0000,
  306.     environment_Vacuum =     0x0001,
  307.     environment_Magnetic =   0x0002,
  308.     environment_Rebellion =  0x0004,
  309.     environment_LowGravity = 0x0008
  310. };
  311.  
  312. enum {        // player info - same as the game options
  313.     player_single =         0x0001,
  314.     player_MultiCoop =         0x0002,
  315.     player_MultiCarnage =     0x0004
  316.     };
  317.  
  318. enum {        // game options
  319.     game_Multiplayer =             0x0001,
  320.     game_ReplenishAmmo =         0x0002,
  321.     game_ReplenishWeapons =     0x0004,
  322.     game_ReplenishSpecials =     0x0008,
  323.     game_ReplenishMonsters =     0x0010,
  324.     game_NoMotionSensor =         0x0020,
  325.     game_OmniscientMap =         0x0040,
  326.     game_LoseItemsOnDeath =     0x0080,
  327.     game_DebugMap =             0x0100,
  328.     game_KillLimit =             0x0200,
  329.     game_NoTeams =                 0x0400,
  330.     game_PenalizeDying =         0x0800,
  331.     game_PenalizeSuicide =         0x1000,
  332.     game_MapShowsItems =         0x2000,
  333.     game_MapShowsMonsters =     0x4000,
  334.     game_MapShowsProjectiles =     0x8000
  335. };
  336.  
  337. // the mission info data
  338. typedef struct {
  339.    short             environmentCode;
  340.    short             physicsModel;
  341.    short             songIndex;
  342.    unsigned short     missionFlags;
  343.    unsigned short     environmentFlags;
  344.    short             unused[4];
  345.    char             levelName[64];
  346.    long             entryPointFlags;
  347.    short            playerInfo;
  348. } Minfdata;
  349.  
  350. enum {        // platform flags
  351.     platform_InitiallyActive =                     0x00000001,  // inactive if 0
  352.     platform_InitiallyExtended =                   0x00000002,    // high for floor... close for both
  353.     platform_StopsAtEachLevel =                    0x00000004,    // deactivates when it reaches a discrete level.
  354.     platform_StopsAtInitialLevel =                 0x00000008,    // deactivates when it returns to its initial level
  355.     platform_ActivatesAdjacentUponDeactivating =   0x00000010,    // activates adjacent platforms on deactivation
  356.     platform_ExtendsFloorToCeiling =               0x00000020,
  357.     platform_ExtendsFloor =                        0x00000040,    // extends from the floor
  358.     platform_ExtendsCeiling =                      0x00000080,    // extends from the ceiling
  359.     platform_CausesDamage =                        0x00000100,
  360.     platform_NoActivateParent =                    0x00000200,    // does not activate the platform that activated it
  361.     platform_OneShot =                             0x00000400,
  362.     platform_ActivatesLight =                      0x00000800,     // activates floor and ceiling light source when activating
  363.     platform_DeactivatesLight =                    0x00001000,    // deactivates ...
  364.     platform_PlayerControllable =                  0x00002000,    // player can use action key to start and stop
  365.     platform_MonsterControllable =                 0x00004000,
  366.     platform_Safety =                              0x00008000,    // reverses direction when obstructed
  367.     platform_NoExternalActivate =                  0x00010000,    // when active can only be deactivated by itself
  368.     platform_UsesNativeHeights =                   0x00020000,    // complex calcs
  369.     platform_DelaysBeforeActivate =                0x00040000,    // waits max delay before activating
  370.     platform_ActivatesAdjacentUponActivating =     0x00080000,    // activates adjacent plats when activating
  371.     platform_DeactivatesAdjacentUponActivating =   0x00100000,
  372.     platform_DeactivatesAdjacentUponDeactivating = 0x00200000,
  373.     platform_ContractsSlow =                       0x00400000,
  374.     platform_ActivatesAdjacentOnEachLevel =        0x00800000,    // activates adjacent on each level
  375.     platform_Floods =                              0x01000000,    // floor texture changes when at bottom
  376.     platform_Secret =                               0x02000000    // ? doesnt show up on map?
  377. };
  378.  
  379. #if 0
  380. enum /* platform types */
  381. {
  382.     _platform_is_marathon_door,
  383.     _platform_is_marathon_platform,
  384.     _platform_is_noisy_marathon_platform,
  385.     _platform_is_alien_door,
  386.     _platform_is_alien_platform,
  387.     _platform_is_noisy_alien_platform,
  388.     NUMBER_OF_PLATFORM_TYPES
  389. };
  390. #endif
  391.  
  392. // the platform data
  393. typedef struct {
  394.    short             type;
  395.    short             speed;
  396.    short             delay;
  397.    short             maxHeight;    // calced for you if ommited, -1
  398.    short             minHeight;    // calced for you if ommited, -1
  399.    unsigned long     flags;        
  400.    short             ownerPolygonIndex;
  401.    short             unused[8];
  402. } platdata;
  403.  
  404. enum // flags for object_frequency_definition 
  405.     {
  406.     _reappears_in_random_location= 0x0001
  407.     };
  408.  
  409. #define _random_location_off_mask    0xFFFE
  410.  
  411. // there are 128 of these.  Monsters are the first 64, and items the second 64
  412. typedef struct {
  413.     short     flags;
  414.     short     initial_count; // initial qty. (can be greater than maximum_count)
  415.     short    minimum_count; // qty > this
  416.     short     maximum_count; // qty < this
  417.     short     random_count; // maximum random occurences of the object UInt16 random_chance; // in (0, 65535]
  418.     short    frequency;
  419.     } placData;
  420.  
  421. // the notes that appear in the map view
  422. typedef struct {
  423.     short        type;    // set to 0
  424.     short        x;
  425.     short        y;
  426.     short        polyNum;    // the poly the x,y coords end up in
  427.     char        text[64];    // the text
  428.     } NOTEdata;
  429.     
  430.  
  431. // the level data after it is read in from disk
  432. // this is how the level is stored in ram.
  433. typedef struct {
  434.     long            numPoints;
  435.     PNTSdata        *thePoints;
  436.     long            numExtendedPts;        // actually are called end points
  437.     EPNTdata        *theExtendedPts;
  438.     long            numLines;
  439.     LINSdata        *theLines;
  440.     long            numSides;
  441.     SIDSdata        *theSides;
  442.     long            numPolys;
  443.     POLYdata        *thePolys;
  444.     long            numLites;
  445.     LITEdata        *theLites;
  446.     long            numObjects;
  447.     OBJSdata        *theObjects;
  448.     long            numMinfos;
  449.     Minfdata        *theMissionInfo;
  450.     long            numPlatforms;
  451.     platdata        *thePlatforms;
  452.     long            numiidxs;        // after I know what all these are then...
  453.     Ptr                theiidxs;        // do not put these into the map file!!!!!!
  454.     long            numNOTEs;
  455.     NOTEdata        *theNOTEs;
  456.     long            numplacs;
  457.     placData        *theplacs;
  458.     short            numNames;
  459.     levelName        *levelAuthor;
  460.     Handle            terminalTexts[10]; // the text for the terminal messages
  461.     Boolean            readIn;            // has this level been read in once yet?
  462.     Boolean            deleteMe;        // should we write out this level?
  463.     mapHeader        *theMapHeader;
  464.     Ptr                ownerDocument;    // an editorDoc instance that owns this map
  465.     } levelData;
  466.  
  467. // the map file.  Not all levels need to be in memory
  468. typedef struct {
  469.     mapHeader        theMapHeader;
  470.     levelInfo        *theLevelInfo;
  471.     levelData        **theLevelData;
  472.     } marathonMap;
  473.  
  474.  
  475.  
  476.